﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Domain.Repositories;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.VirtualExchange.Models;
using JXT.PrimaryKey.Batman.Domain.Quotation.Models;

namespace JXT.PrimaryKey.Batman.Domain.VirtualExchange.Repositories
{
    public interface IUserTransactionDetailRepository : IRepository<UserTransactionDetail>,
        IWriteRepository<UserTransactionDetail, int>,
        ISpecificationRepository<UserTransactionDetail>
    {
        /// <summary>
        /// 收益排行
        /// </summary>
        /// <param name="pagedSpecification">查找条件</param>
        /// <returns>根据收益排好序的UserTransactionDetail对象集合</returns>
        IEnumerable<UserTransactionDetail> GetListByProfit(IPagedSpecification<UserTransactionDetail> pagedSpecification);

        /// <summary>
        /// 交易额排行
        /// </summary>
        /// <param name="pagedSpecification">查找条件</param>
        /// <returns>根据交易额排好序的UserTransactionDetail对象集合</returns>
        IEnumerable<UserTransactionDetail> GetListByTurnover(IPagedSpecification<UserTransactionDetail> pagedSpecification);

        /// <summary>
        /// 获取某个用户的交易信息
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">账号绑定类型id</param>
        /// <param name="counttype">收益类型(日收益，周收益)</param>
        /// <returns></returns>
        UserTransactionDetail GetSingleByUserId(IPagedSpecification<UserTransactionDetail> pagedSpecification);

        /// <summary>
        /// 获取最新一期数据的时间
        /// </summary>
        /// <returns>时间</returns>
        DateTime? GetLastDateTime(RankCountType rankCountType = RankCountType.Unknown);

        /// <summary>
        /// 获取给定时间前的第一条日交易统计记录
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">类型id</param>
        /// <param name="time">时间</param>
        /// <param name="type">统计类型</param>
        /// <returns></returns>
        UserTransactionDetail GetLastSingle(int userId, int typeId, DateTime time, RankCountType type);

        /// <summary>
        /// 获取给定时间内或者之前的第一条日交易统计记录
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="typeId">类型id</param>
        /// <param name="time">时间</param>
        /// <param name="type">统计类型</param>
        /// <returns></returns>
        UserTransactionDetail GetCurrentOrLastSingle(int userId, int typeId, DateTime time, RankCountType type);
    }
}
